package de.fhhannover.inform.hnefatafl.gui;

import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;


public class ManualPanel extends JPanel{
	
private static final long serialVersionUID = -8860204251354754377L;

	private JScrollPane manualScroller;
	private JTextArea manualText;
	private JButton zurueck;
	
	public Image background;
	
	public ManualPanel(){
		this.setSize(800,600);
		GridBagLayout thisLayout = new GridBagLayout();
		this.setLayout(thisLayout);
		thisLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
		thisLayout.rowHeights = new int[] {7, 7, 7, 7};
		thisLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
		thisLayout.columnWidths = new int[] {7, 7, 7, 7};
		
		
		try {
			   background        = ImageIO.read(ImageIO.class.getResource("/res/hnefatafl_hintergrund1_1.png"));
			}
			catch(IOException ex) {
			   System.out.println("Ausnahmefehler beim Laden einer Grafik!\nEine Grafik konnte nicht gelesen werden!");
			   ex.printStackTrace();
			}
			catch(IllegalArgumentException ex) {
			   System.out.println("Ausnahmefehler beim Laden einer Grafik!\nEine Grafik wurde nicht gefunden!");
			   ex.printStackTrace();
			}
		

		zurueck = new JButton("Zurueck");
		this.add(zurueck, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
		zurueck.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				GUIController.getInstance().switchManualToStart();
				
			}});

		
		manualScroller = new JScrollPane();
		manualText = new JTextArea();
		manualScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		manualScroller.setViewportView(manualText);
		manualText.setText("			Hier steht irgendwann mal die Beschreibung		");
		manualText.setEditable(false);
		manualText.setPreferredSize(new java.awt.Dimension(419, 288));
		this.add(manualScroller, new GridBagConstraints(0, 0, 4, 3, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));		
			
	}
	
	@Override
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		g.drawImage(background, 0, 0, this);
	}
		
}
